<template>
  <div class="container">
    <DataList
      ref="dataList"
      :propAutoFetchData="true"
      :propNoCheck="true"
      :propSearchFields="['materialName','materialSpec', 'materialCode']"
      :propSearchTextAppend="'名称/规格/编码'"
      propUrl="/base/hospital_materials/pageCommon"
      :vanFieldLabelWith5="true"
      :showFieldList="cpShowFieldList"
      :sortDefault="{field: 'materialName',type: 'asc'}"
      @click="itemClick"
    >
    </DataList>


    <!--表单-->
    <customDrawer  title="规格列表" ref="customDrawerOrder" :autoHide="false" p94Only placement="right" :footer="null">
      <template #content>
        <DataList
          ref="dataListDtl"
          :propAutoFetchData="false"
          :propNoCheck="true"
          :propSearchFields="['materialSpec','certificateNo']"
          :propSearchTextAppend="'规格、注册证号'"
          propUrl="/base/material_specs/pageCommon"
          :showFieldList="cpDtlshowFieldList"
          :vanFieldLabelWith5="true"
          :sortDefault="{field: 'materialSpec',type: 'asc'}"
        >
        </DataList>
      </template>
    </customDrawer>
  </div>
</template>

<script>

export default {
  help: '已供货商品-列表',
  data() {
    return {
      form: {}
    }
  },

  methods: {
    itemClick(item) {
      this.form = item
      let wrapper = this.$newWrapper()
      wrapper.eq('materialId', this.form.materialId)
      this.$refs.dataListDtl.setQueryWrapper(wrapper)
      this.$refs.customDrawerOrder.show()
    }
  },
  computed: {
    cpShowFieldList() {

      let fieldList = [
        { label: '名称', name: 'materialName', span: 24, isTitle: true },
        {
          label: '商品类型', name: 'materialTypeCode', span: 12, isTitleSub: true,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.baseMatrType,
            multiple: true
          }
        },
        { label: '商品规格', name: 'materialSpec', span: 24 },
        { label: '商品编码', name: 'materialCode', span: 12 },
        { label: '价格', name: 'price', span: 12, filterDisabled: true, sortDisabled: true },
        { label: '单品单位', name: 'unit', span: 12, filterDisabled: true, sortDisabled: true },
        {
          label: '订单单位',
          name: 'orderUnit',
          span: 12,
          filterDisabled: true,
          sortDisabled: true
        },
        { label: '单位比率', name: 'orderQty', span: 12, filterDisabled: true, sortDisabled: true },
        { label: '品类', name: 'catalogName', span: 12 },
        { label: 'HRP编码', name: 'materialHrpCode', span: 24 },
        { label: '生产厂商', name: 'manufacturerName', span: 24 },
        {
          label: '寄售', name: 'isConsignment', span: 12, flagBoolean: true,
          queryType: this.constCommon.formItemType.switch.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo
          }
        },

        {
          label: '标签管理', name: 'isOneThingOneYard', span: 12, flagBoolean: true,
          queryType: this.constCommon.formItemType.switch.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo
          }
        },

        { label: '中标号', name: 'bidno', span: 24 },
        { label: 'UDI', name: 'udi', span: 24 }
      ]
      fieldList = [...fieldList, ...this.constCommon.filterCommon.spAndHp()]
      return fieldList
    },

    // 明细
    cpDtlshowFieldList() {

      let fieldList = [
        {label:'规格',name:'materialSpec',span:24, isTitle: true},
        {label:'ERP编码',name:'materialErpCode',span:24},
        {label:'单价',name:'price',span:12,filterDisabled: true,sortDisabled: true},
        {label:'单品单位',name:'unit',span:12,filterDisabled: true,sortDisabled: true},
        {label:'订单单位',name:'orderUnit',span:12,filterDisabled: true,sortDisabled: true},
        {label:'单位比率',name:'orderQty',span:12,filterDisabled: true,sortDisabled: true},
        {label:'注册证号',name:'certificateNo',span:24},
        {label:'注册证开始',name:'certificateExpiredStartDate',span:12,queryType: this.constCommon.formItemType.datePickerBetween.name},
        {label:'注册证截止',name:'certificateExpiredDate',span:12,queryType: this.constCommon.formItemType.datePickerBetween.name},
        {label:'标签管理',name:'isOneThingOneYard',span:12,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo,
          }},
        {label:'寄售',name:'isConsignment',span:12,
          queryType: this.constCommon.formItemType.selectDict.name,
          queryConfig: {
            dictType: this.constCommon.dictType.commonYesNo,
          }},
        {label:'医保代码(20位)',name:'hisMedicareNo',span:24},
        {label:'医保名称(20位)',name:'hisMedicareName',span:24},
        {label:'医保代码(27位)',name:'hisMedicareNo2',span:24},
        {label:'医保名称(27位)',name:'hisMedicareName2',span:24},
      ]
      return fieldList
    }
  }
}
</script>
